<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <meta charset="ISO-8859-1">
  <title>课程管理系统</title>
  <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<!-- 插入公共头部 -->
<div class="container my-2" th:insert="header :: commonHeader"></div>
<div class="container my-2">
  <div class="container-fluid">
    <div class="row">
      <!--侧边栏-->
      <div th:replace="~{header :: sidebar }">...</div>
      <div class="col-10">
        <div class=" ">
          <div class="container my-2">
            <h1>课程列表</h1>
            <a th:href="@{/Course/showCourseForm}" class="btn btn-primary btn-sm mb-3"> 新增 </a>
            <h1  class="text-primary"></h1>
            <nav class="navbar navbar-light bg-light">
              <form id="query-form" action="/Course/query" method="get">
                <h6 class="text-secondary">查找课程姓名</h6><input type="text" id="name-input" name="inpname" placeholder="课程名">
                <button type="button" class="btn btn-info"onclick="queryCourse()">搜索</button>
              </form>
              <hr>
              <a th:href="@{/Course/}"> 回到课程列表</a>
              <script>
                function queryCourse() {
                  var Name = document.getElementById("name-input").value;
                  var url = "/Course/query" + encodeURIComponent(Name);
                  window.location.href = url;
                }
              </script>
            </nav>
            <table border="1" class="table table-striped table-responsive-md">
              <thead>
              <tr>
                <th>
                  <a th:href="@{'/Course/page/' + ${currentPage} + '?sortField=id&sortDir=' + ${reverseSortDir}}">
                    课程号</a>
                </th>
                <th>
                  <a th:href="@{'/Course/page/' + ${currentPage} + '?sortField=name&sortDir=' + ${reverseSortDir}}">
                    课程名</a>
                </th>
                <th>
                  <a th:href="@{'/Course/page/' + ${currentPage} + '?sortField=credit&sortDir=' + ${reverseSortDir}}">
                    学分</a>
                </th>
                <th> 功能 </th>
              </tr>
              </thead>
              <tbody>
              <tr th:each="course: ${listCourse}">
                <td th:text="${course.id}"></td>
                <td th:text="${course.name}"></td>
                <td th:text="${course.credit}"></td>
                <td> <a th:href="@{/Course/showFormForUpdate/{id}(id=${course.id})}" class="btn btn-primary">更新</a>
                  <a th:href="@{/Course/deleteCourse/{id}(id=${course.id})}" class="btn btn-danger">删除</a>
                </td>
              </tr>
              </tbody>
            </table>
            <div th:if = "${totalPages > 1}">
              <div class = "row col-12">
                <div class = "col-3">
                  课程总数: [[${totalItems}]]    <!--/* 在thymeleaf模板引擎中获取Model中数据：var items = [[${user_name}]];  */-->
                </div>
                <div class = "col-4">
					<span th:each="i: ${#numbers.sequence(1, totalPages)}">
						<a th:if="${currentPage != i}" th:href="@{'/Course/page/' + ${i}+ '?sortField=' + ${sortField} + '&sortDir=' + ${sortDir}}">[[${i}]]</a>
						<span th:unless="${currentPage != i}">[[${i}]]</span>  &nbsp; &nbsp;
					</span>
                </div>
                <div class = "col-2">
                  第<a th:text="${currentPage}"></a>页
                  /共<a th:text="${totalPages}"></a>页
                </div>
                <div class = "col-3">
                  <a th:if="${currentPage > 1}" th:href="@{'/Course/page/' + ${1}+ '?sortField=' + ${sortField} + '&sortDir=' + ${sortDir}}">首页</a>
                  <span th:unless="${currentPage > 1}">首页</span>
                  <a th:if="${currentPage > 1}" th:href="@{'/Course/page/' + ${currentPage - 1}+ '?sortField=' + ${sortField} + '&sortDir=' + ${sortDir}}">上一页</a>
                  <span th:unless="${currentPage > 1}">上一页</span>
                  <a th:if="${currentPage < totalPages}" th:href="@{'/Course/page/' + ${currentPage+1}+ '?sortField=' + ${sortField} + '&sortDir=' + ${sortDir}}">下一页</a>
                  <span th:unless="${currentPage < totalPages}">下一页</span>
                  <a th:if="${currentPage < totalPages}" th:href="@{'/Course/page/' + ${totalPages}+ '?sortField=' + ${sortField} + '&sortDir=' + ${sortDir}}">尾页</a>
                  <span th:unless="${currentPage < totalPages}">尾页</span>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<br><br><br><br><br>
<!-- 插入公共底部 -->
<div  th:insert="header ::bottom"></div>
</body>
</html>